package com.appcenter.message.controller;


import com.appcenter.jz.config.ErrorJsonResult;
import com.appcenter.jz.config.JsonResult;
import com.appcenter.message.input.LoadManageMessageListPageInput;
import com.appcenter.message.input.LoadManageMessageTargetListPageInput;
import com.appcenter.message.input.SearchManageMessageListInput;
import com.appcenter.message.input.SearchManageMessageTargetListInput;
import com.appcenter.message.service.MessageTargetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/services/jzmessagecenterservice/MessageTarget")
@Api(value="消息对应人员",description = "消息对应人员")
public class MessageTargetConterController {
    @Autowired
    MessageTargetsService messageTargetsService;


    @ApiOperation(value = "查询平台消息信息", notes = "查询平台消息信息",produces = "application/json")
    @PostMapping("/LoadManageMessageTargetListPage")
    public ResponseEntity<JsonResult> LoadManageMessageTargetListPage(@RequestBody LoadManageMessageTargetListPageInput input) throws Exception {
        JsonResult r = new JsonResult();
        try {
            r.setResult(messageTargetsService.LoadManageMessageTargetListPage(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);


    }



    @ApiOperation(value = "加载平台消息信息", notes = "加载平台消息信息",produces = "application/json")
    @PostMapping("/SearchManageMessageTargetList")
    public ResponseEntity<JsonResult> SearchManageMessageTargetList(@RequestBody SearchManageMessageTargetListInput input) throws Exception {
        JsonResult r = new JsonResult();
        try {
            r.setResult(messageTargetsService.SearchManageMessageTargetList(input));
        } catch (ErrorJsonResult e) {
            r.setResult(e.getClass().getName() + ":" + e.getMessage());
            r.setError(e);
            e.printStackTrace();
            return ResponseEntity.status(500).body(r);
        }
        return ResponseEntity.ok(r);


    }


}
